Create an object at a given address: Difference between revisions
Create an object at a given address (view source)
Revision as of 10:50, 12 September 2021
, 2 years ago→{{header|8086 Assembly}}: better comment alignment
Puppydrum64 (talk | contribs) m (→{{header|8086 Assembly}}: Clarification, formatting, and better examples.) |
Puppydrum64 (talk | contribs) m (→{{header|8086 Assembly}}: better comment alignment) |
||
Line 64:
=={{header|8086 Assembly}}==
This example uses UASM to assemble MS-DOS compatible code.
<lang asm>
.
.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 ;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
mov word ptr [ds:tempLong_LoWord],ax
mov ax, 0040h
mov word ptr [ds:tempLong_HiWord],ax
;get the address of a variable
mov ax, tempLong_LoWord
=={{header|Ada}}==
|