Create an object at a given address: Difference between revisions

m
→‎{{header|8086 Assembly}}: better comment alignment
m (→‎{{header|8086 Assembly}}: Clarification, formatting, and better examples.)
m (→‎{{header|8086 Assembly}}: better comment alignment)
Line 64:
=={{header|8086 Assembly}}==
This example uses UASM to assemble MS-DOS compatible code.
<lang asm>
<lang asm>.model small ;specify memory model to use
.stackmodel small 1024 ;setspecify memory model upto stackuse
.stack 1024 ;set up stack
 
.data ;data segment
 
UserRam BYTE 256 DUP (0) ;allocate 256 bytes of user RAM, initialized to zero.
 
tempByte equ UserRam
tempByte equ UserRam ;define a few labels for clarity
tempWord equ UserRam+2
tempLong_LoWord equ UserRam+4
tempLong_HiWord equ UserRam+6
 
.code ;code segment
 
mov ax, @data
Line 81 ⟶ 83:
 
mov ax, @code
mov es, ax ;load segment registers with the appropriate segments.
 
; now there is no need to use "mov ax, seg UserRam" since we've already loaded the data segment into DS
Line 88 ⟶ 90:
;store an integer value into memory
 
mov ax, 1000h ;load the value 0x1000 into AX
mov word ptr [ds:tempLong_LoWord],ax ;store 0x1000 into tempLong_LoWord
mov ax, 0040h ;the 8086 is 16-bit so we have to load the pieces separately.
mov word ptr [ds:tempLong_HiWord],ax ;store 0x0040 into tempLong_HiWord
 
;get the address of a variable
mov ax, tempLong_LoWord ;without "word ptr" and brackets, the assembler interprets a label as a constant.</lang>
 
=={{header|Ada}}==
1,489

edits